package com.sdy.dao.mysql;

import com.sdy.po.SerialPO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface SerialMapper {

    @Select("select * from po_serialpo where companyId = #{id}")
    @Results({
            @Result(column = "parmId",property = "parmId"),
            @Result(column="parmId",property="parm",one = @One(select = "com.sdy.dao.mysql.ParmMapper.selectById",fetchType = FetchType.EAGER))
    })
    List<SerialPO> getSerialListByCompanyId(@Param("id") Integer id);

    @Update("update po_serialPO set serialNumber = #{serial.serialNumber}," +
                                 " baudRate = #{serial.baudRate}," +
                                 " checkoutBit = #{serial.checkoutBit}," +
                                 " dataBit = #{serial.dataBit}," +
                                 " stopBit = #{serial.stopBit}," +
                                 " parmCN = #{serial.parmCN}," +
                                 " parm = #{serial.parm}," +
                                 " isHandled = #{serial.isHandled}" +
            " where companyId = #{serial.companyId} and parm = #{serial.parm}")
    Boolean update(@Param("serial") SerialPO serialPO);


}
